# -*- coding: utf-8 -*-
# @Create_time   : :
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :.py
# @Desc          :

from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms_point_hi.ods.dwm_yl_rt_ssmx_bill_detail_hi import jms_ods__dwm_yl_rt_ssmx_bill_detail_hi
from jms_point_hi.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage

jms_dwd__dwd_wide_yl_rt_ssmx_bill_detail_hi = SparkSqlOperator(
    task_id='jms_dwd__dwd_wide_yl_rt_ssmx_bill_detail_hi',
    email=['lukunming@jtexpress.com','yl_etl@yl-scm.com'],
    master='yarn',
    name='jms_dwd__dwd_wide_yl_rt_ssmx_bill_detail_hi_{{ execution_date | cst_hour }}',
    sql='jms_point_hi/dwd/dwd_wide_yl_rt_ssmx_bill_detail_hi/execute.sql',
    pool_slots=2,
    driver_cores=2,
    driver_memory='3g',
    executor_cores=4,
    executor_memory='10G',
    num_executors=30,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          'spark.dynamicAllocation.maxExecutors'             : 40,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 600,
          'spark.network.timeout' : 600,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '3G',
          'spark.sql.shuffle.partitions'                     : 600,
          # 'spark.sql.adaptive.enabled': 'true',
          # 'spark.sql.adaptive.shuffle.targetPostShuffleInputSize': 1258291200
          'spark.executor.extraJavaOptions'                  : '-XX:+UseG1GC -XX:ParallelGCThreads=6',
          'spark.shuffle.memoryFraction'                     : 0.8,
          # 'spark.storage.memoryFraction'                     : 0.3
          # 'spark.reducer.maxSizeInFlight': '96M',
          # 'spark.shuffle.file.buffer': '64k'
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 30,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 30,  # 最大分区
              # 'hive.merge.sparkfiles':'true',
              # 'hive.merge.smallfiles.avgsize':'64m'

              },
    yarn_queue='warehouse',
    execution_timeout=timedelta(minutes=25),
    retries=0,
    sla=timedelta(hours=2))


jms_dwd__dwd_wide_yl_rt_ssmx_bill_detail_hi << [jms_ods__dwm_yl_rt_ssmx_bill_detail_hi,jms_dim__dim_network_whole_massage]


